package applet;

import java.applet.Applet;
import java.applet.AudioClip;
import java.io.File;
import java.net.MalformedURLException;

class SoundThread2 implements Runnable {
	AudioClip audioClip;
	File audioFile;
	public boolean isPlay = true;

	public SoundThread2() {
		super();
		audioFile = new File("D:\\Users\\jingxin\\Music\\AU_file\\alarm.au");
		try {
			audioClip = Applet.newAudioClip(audioFile.toURL());
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
	}

	public void run() {
		synchronized (this) {
			while (true) {
				if (isPlay == true) {
					audioClip.play();
				}
				if (isPlay == false) {
					try {
						this.wait();
					} catch (InterruptedException e) {

						e.printStackTrace();
					}
				}
				try {
					this.wait(1000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}

	}
}
